package mutsumimod.monitors;

import basemod.ReflectionHacks;
import basemod.interfaces.PostUpdateSubscriber;
import com.megacrit.cardcrawl.cards.AbstractCard;
import com.megacrit.cardcrawl.characters.AbstractPlayer;
import com.megacrit.cardcrawl.core.Settings;
import com.megacrit.cardcrawl.dungeons.AbstractDungeon;
import mutsumimod.cards.BaseCard;
import mutsumimod.patches.CopyPatch;

public class CopyMonitor extends BaseMonitor implements PostUpdateSubscriber {

    public static AbstractCard copyCard = null;
    public static boolean isManuallySelected = false;

    public static void setCopyCard(AbstractCard card) {
        copyCard = card;
        isManuallySelected = true;
        CopyPatch.AbstractCardFieldPatch.inChoosingTarget.set(copyCard, true);

        copyCard.current_x = (float) Settings.WIDTH / 4.0F;
        copyCard.target_x = (float) Settings.WIDTH / 4.0F;
        copyCard.current_y = (float) Settings.HEIGHT / 4.0F;
        copyCard.target_y = (float) Settings.HEIGHT / 4.0F;

        copyCard.lighten(true);
        copyCard.drawScale = 0.50F;
        copyCard.targetDrawScale = 0.50F;
    }

    public static void clearCopyCard() {
        copyCard = null;
        isManuallySelected = false;
        AbstractDungeon.player.releaseCard();
        //AbstractDungeon.player.isDraggingCard = false;
        //AbstractDungeon.player.hoveredCard= null;
        //ReflectionHacks.setPrivate(AbstractDungeon.player, AbstractPlayer.class, "isUsingClickDragControl",false);
    }

    @Override
    public void receivePostUpdate() {
        if(AbstractDungeon.player != null){
            if(isManuallySelected) {
                AbstractDungeon.player.isDraggingCard = true;
                AbstractDungeon.player.hoveredCard= copyCard;
                ReflectionHacks.setPrivate(AbstractDungeon.player, AbstractPlayer.class, "isUsingClickDragControl",true);
            }
        }
    }



}
